package Ventanas;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;

import ClasesBasicas.Cliente;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.awt.Toolkit;
import javax.swing.JLabel;
import javax.swing.ImageIcon;

public class ventanaClienteLogeado extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4226119802310180612L;
	private JPanel contentPane;
	private Cliente c = new Cliente();
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ventanaClienteLogeado frame = new ventanaClienteLogeado();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ventanaClienteLogeado() {
		setResizable(false);
		setIconImage(Toolkit.getDefaultToolkit().getImage("src\\Fotos\\txoPizzeria.jpg"));
		setTitle("Cliente");
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 449, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnVolver = new JButton("Volver");
		btnVolver.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				ventanaTipoUsuario vTipoUsuario= new ventanaTipoUsuario();
				vTipoUsuario.getFrame().setLocationRelativeTo(null);
				vTipoUsuario.getFrame().setVisible(true);
			}
		});
		btnVolver.setBounds(20, 11, 75, 23);
		contentPane.add(btnVolver);
		
		JButton btnHacerPedido = new JButton("Hacer Pedido");
		btnHacerPedido.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				ventanaHacerPedido v;
				try {
					v = new ventanaHacerPedido();
					v.setLocationRelativeTo(null);
					v.setC(c);
					v.setVisible(true);
				} catch (ClassNotFoundException | SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			
			}
		});
		btnHacerPedido.setBounds(148, 52, 142, 23);
		contentPane.add(btnHacerPedido);
		
		JButton btnSugerirPizza = new JButton("Sugerir Pizza");
		btnSugerirPizza.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				setVisible(false);
				ventanaCrearPizzaSugerida v=new ventanaCrearPizzaSugerida();
				v.setC(c);
				v.setLocationRelativeTo(null);
				v.setVisible(true);
				
			}
		});
		btnSugerirPizza.setBounds(148, 99, 142, 23);
		contentPane.add(btnSugerirPizza);
		
		JButton btnVotarPizza = new JButton("Votar Pizza");
		btnVotarPizza.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				ventanaVotos v;
				try {
					Cliente c=getCliente();
					v = new ventanaVotos();
					v.setC(c);
					v.setLocationRelativeTo(null);
					v.setVisible(true);
				} catch (ClassNotFoundException | SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
			}
		});
		btnVotarPizza.setBounds(148, 144, 142, 23);
		contentPane.add(btnVotarPizza);
		
		JButton btnCuestionario = new JButton("Cuestionario");
		btnCuestionario.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
				ventanaCuestionario v=new ventanaCuestionario();
				v.setC(c);
				v.setLocationRelativeTo(null);
				v.setVisible(true);
			}
		});
		btnCuestionario.setBounds(148, 191, 142, 23);
		contentPane.add(btnCuestionario);
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon("src\\Fotos\\fondo-textured-blanco-y-azul-abstracto-5013168.jpg"));
		label.setBounds(0, 0, 433, 261);
		contentPane.add(label);
		
	}
	
	
	public void setCliente(Cliente c) {
		// TODO Auto-generated method stub
		this.c = c;
	}
	public  Cliente getCliente(){
		return c;
	}
}
